#include "searcher.h"
#include <iostream>

#if 0
int main()
{
  searcher::Index index;
  bool ret = index.Build("../data/temp/raw_input");
  if(!ret)
  {
    std::cout<<"Build Failed\n";
    return 1;
  }
  auto* inverted_list = index.GetInvertedList("filesystem");
  if(inverted_list == nullptr)
  {
    std::cout<<"Get Failed\n";
    return 1; 
  }

  for(auto weight : *inverted_list){
    std::cout<<"id:"<<weight.doc_id<<" "<<"weight:"<<weight.weight<<std::endl;
    const auto* doc_info = index.GetDocInfo(weight.doc_id);
    std::cout<<"title:"<<doc_info->title<<std::endl;
    std::cout<<"url:"<<doc_info->url<<std::endl;
  }
  return 0;
}
#endif

int main()
{
  searcher::Searcher searcher;
  bool ret = searcher.Init("../data/temp/raw_input");
  if(!ret)
  {
    std::cout<<"初始化失败!"<<std::endl;
    return 1;
  }
  std::string query = "filesystem";
  std::string result;
  searcher.Search(query, &result);
  std::cout<<"result"<<result<<std::endl;
  return 0;
}
